

#include "..\System\os_link.h"
#include "..\User\led.h"
#include "..\User\cmp.h"

#define DIS_DOT     0x20        // 0010 0000, 
#define DIS_BLACK   0x10        
#define DIS_        0x11

s_u8_t code t_display[]={                       //????
//   0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
    0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,
//black  -     H    J    K    L    N    o   P    U     t    G    Q    r   M    y
    0x00,0x40,0x76,0x1E,0x70,0x38,0x37,0x5C,0x73,0x3E,0x78,0x3d,0x67,0x50,0x37,0x6e,
    0xBF,0x86,0xDB,0xCF,0xE6,0xED,0xFD,0x87,0xFF,0xEF,0x46};    //0. 1. 2. 3. 4. 5. 6. 7. 8. 9. -1

s_u8_t code T_COM[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};      //??

s_u8_t LED8[8] = {0,0,0,0,0,0,0,0};


void sendData(void) MCUCFG_C51USING {
		static s_u8_t display_index = 0;
        bit lowPv = isLowPv();
        if(lowPv) {
			return;
        }
        P7 = ~T_COM[7-display_index];
        P6 = ~t_display[LED8[display_index]];
        if(++display_index >= 8) {
	    display_index = 0;  // ѭ����ʾ
        }
}


void refreshDisplay(s_u16_t Test_cnt) MCUCFG_C51USING 
{
    s_u8_t  i;
    
    LED8[3] = Test_cnt / 10000;
    LED8[4] = (Test_cnt % 10000) / 1000;
    LED8[5] = (Test_cnt % 1000) / 100;
    LED8[6] = (Test_cnt % 100) / 10;
    LED8[7] = Test_cnt % 10;
    
    for(i=3; i<7; i++)  //消无效0
    {
        if(LED8[i] > 0) break;
        LED8[i] = DIS_BLACK;
    }
}

void close(void) 
{
    P7 = 0xff;     //关闭显示，省电
}